package com.springcloudalibaba.controller;

import com.springcloud.entities.CommonResult;
import com.springcloud.entities.PayMent;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;

@RestController
public class PaymentController {
    @Value("${server.port}")
    private String serverPort;
    public static HashMap<Long, PayMent> hashMap = new HashMap<>();
    static {
        hashMap.put(1L,new PayMent(1L,"28a8c1e3bc2742d8848569891fb42181"));
        hashMap.put(2L,new PayMent(2L,"bba8c1e3bc2742d8848569891ac32182"));
        hashMap.put(3L,new PayMent(3L,"6ua8c1e3bc2742d8848569891xt92183"));
    }

    @GetMapping(value = "/paymentSQL/{id}")
    public CommonResult<PayMent> paymentSQL(@PathVariable("id") Long id) {
        PayMent payment = hashMap.get(id);
        CommonResult commonResult =
                new CommonResult(200, "from mysql,serverPort:"
                        + serverPort, payment);
        return commonResult;
    }
}
